<template>
	<div class="container">
		<div v-if="tableData == ''">暂无审核订单，您今日的审核订单已全部完成！</div>
    <div v-else>
		<!-- <div> -->
			<div
				style="background-color: #fff;margin-bottom: 1px;border-radius: 4px 0px;padding:10px;height: 60px;line-height: 30px;">
				<el-row :gutter="20">
					<el-col :span="6">
						<div>订单号：{{ tableData.trade_no }}</div>
					</el-col>
					<el-col :span="6">
						<div>下单时间：{{ tableData.create_time }}</div>
					</el-col>
					<el-col :span="6">
						<div>来源：{{ tableData.source }}</div>
					</el-col>
					<el-col :span="6">
						订单号：<el-input v-model="searchId.orderId" style="width: 210px;" clearable /><el-button
							style="margin-left: 5px;" @click="handleSet">设置</el-button>
					</el-col>
				</el-row>
			</div>
			<div class="border_cls" style="border-top-right-radius: 0px;border-top-left-radius: 0px;">
				<el-row>
					<el-col>
						<div class="font_cls">订单信息</div>
					</el-col>
				</el-row>
				<el-row :gutter="20">
					<el-col :span="6">合同类型</el-col>
					<el-col :span="6">免押类型</el-col>
					<el-col :span="6">免押金额</el-col>
					<el-col :span="6">已交押金</el-col>
				</el-row>
				<el-row :gutter="20">
					<el-col :span="6">
						<div class="bor_cls">{{ tableData.pay_type == 1 ? "智能合同代扣" :
              tableData.pay_type == 2 ? "支付宝预授权（" + (tableData.rights_auth_no != 0 ? "已授权代扣" : "未授权代扣") + "）" :
                "花呗" }}</div>
					</el-col>
					<el-col :span="6">
						<div class="bor_cls">
							{{ tableData.foregift_deduct == 0 ? "未授权免押" : tableData.foregift_pay > 0 ? "部分免押" : "押金全免" }}
						</div>
					</el-col>
					<el-col :span="6">
						<div class="bor_cls">￥{{ tableData.foregift_deduct == null ? '0.00' : tableData.foregift_deduct }}</div>
					</el-col>
					<el-col :span="6">
						<div class="bor_cls">￥{{ tableData.foregift_pay == null ? '0.00' : tableData.foregift_pay }}</div>
					</el-col>
				</el-row>
				<el-row :gutter="20">
					<el-col :span="18">
						风控信息： {{ tableData.is_skip == 1 ? '【未风控】商家跳过风控' : tableData.risk }}
						<el-button size="mini" class="border-btn" style="padding: 0 1px;"
							@click="handleOrderData(tableData)">查看布尔风控数据
						</el-button>
						<el-button size="mini" class="border-btn" style="padding: 0 1px;" @click="radarDialog(tableData)">查看雷达风控数据
						</el-button>
						<el-button v-if="tableData.is_credit_select==1" size="mini" class="border-btn" style="padding: 0 1px;"
							@click="creditDialog(tableData)">请求查询征信</el-button>
						<el-button v-else size="mini" class="border-btn"
							style="padding: 0 1px;border-color: #ff9f37;color: #ff9f37;"
							@click="creditDialog2(tableData)">查看征信风控数据</el-button>
					</el-col>
					<el-col :span="6" style="margin-top: 10px;">
						签署协议：
						<el-tooltip class="item" effect="dark" content="用户授权协议已签署" placement="top-start">
							<img v-if="tableData.flow_id_2" src="../../assets/images/db-signed.png" alt="用户授权协议已签署" />
						</el-tooltip>
						<el-tooltip class="item" effect="dark" content="用户授权协议未签署" placement="top-start">
							<img v-if="!tableData.flow_id_2" src="../../assets/images/db-unsign.png" alt="用户授权协议未签署" />
						</el-tooltip>

						<el-tooltip class="item" effect="dark" content="个人征信授权书已签署" placement="top-start">
							<img v-if="tableData.flow_id_3" src="../../assets/images/db-signed.png" alt="个人征信授权书已签署" />
						</el-tooltip>
						<el-tooltip class="item" effect="dark" content="个人征信授权书未签署" placement="top-start">
							<img v-if="!tableData.flow_id_3" src="../../assets/images/db-unsign.png" alt="个人征信授权书未签署" />
						</el-tooltip>
						</el-tooltip>
						<el-tooltip class="item" effect="dark" content="租赁合同未签署" placement="top-start">
							<img v-if="tableData.sign_status != 1 && tableData.sign_status != 2" src="../../assets/images/unsign.png"
								alt="合同未签署" />
						</el-tooltip>
						<el-tooltip class="item" effect="dark" content="租赁合同签署中" placement="top-start">
							<img v-if="tableData.sign_status == 1" src="../../assets/images/signing.png" alt="合同签署中" />
						</el-tooltip>
						<el-tooltip class="item" effect="dark" content="租赁合同已签署" placement="top-start">
							<img v-if="tableData.sign_status == 2" src="../../assets/images/signed.png" alt="合同已签署" />
						</el-tooltip>
						<el-tooltip class="item" effect="dark" content="续租订单" placement="top-start">
							<img v-if="tableData.is_renewal == 1" src="../../assets/images/renew.png" alt="续租订单" />
						</el-tooltip>
					</el-col>
				</el-row>
			</div>
			<div class="border_cls">
				<div style="display: flex;">
					<div style="width:20% ;">
						<div class="font_cls">商品信息</div>
						<img style="height:200px;width:200px" :src="$globalObj.imgBaseUrl + tableData.imgurl" class="w-100 h-100">
					</div>
					<div style="width: 80%;">
						<el-row :gutter="20">
							<el-col :span="8">
								<div style="font-size: 16px;">商品ID: {{ tableData.goods_id }}</div>
							</el-col>
							<el-col :span="8">
								<div style="font-size: 16px;">活动商品: {{ tableData.activity_title?tableData.activity_title:'暂无活动' }}</div>
							</el-col>
							<el-col :span="8">
								<div>商品数量：{{ tableData.amount }}</div>
							</el-col>
						</el-row>
						<el-row :gutter="20">
							<el-col :span="8">
								<div>租赁方式：{{ tableData.pact_type }}</div>
							</el-col>
							<el-col :span="8">
								<div>商品名称:({{ tableData.new_grade_title }}){{ tableData.goods_title }}</div>
							</el-col>
							<el-col :span="8">
								<div>套餐方式：{{ tableData.setmeal_title }}</div>
							</el-col>
						</el-row>
						<el-row :gutter="20">
							<el-col :span="1.5"><el-button v-if="tableData.status == 10" size="mini" type="warning"
									@click="openDelivery(tableData.id)">订单发货</el-button></el-col>
							<el-col :span="1.5"><el-button v-if="tableData.status == 10" size="mini" type="danger"
									@click="refuseorder(tableData.id)">拒绝订单</el-button></el-col>
							<el-col :span="1.5"><el-button v-if="tableData.status == 4" size="mini" type="success"
									@click="checkPass(tableData.id)">审核通过</el-button></el-col>
							<el-col :span="1.5"><el-button v-if="tableData.status == 4" size="mini"
									type="danger" @click="refuseOrder2(tableData.id)">审核拒绝</el-button></el-col>
							<!-- <el-col :span="1.5"><el-button v-if="tableData.status == 4&&tableData.seller_id!=1653450768" size="mini"
									type="danger" @click="returnOrder(tableData.id)">转回平台</el-button></el-col> -->
							<el-col :span="1.5"><el-button v-if="tableData.status == 20" size="mini" type="warning"
									@click="confirmReceipt(tableData.id)">确认收货</el-button></el-col>
							<el-col :span="1.5"><el-button v-if="tableData.status == 44" size="mini" type="warning"
									@click="confirmReturn(tableData.id)">确认归还</el-button></el-col>
							<el-col :span="1.5"><el-button
									v-if="[20, 30, 31, 32, 33, 34, 39, 40, 41, 42, 43, 44, 45, 49, 50, 51, 52, 56, 57, 58].indexOf(tableData.status) > -1"
									size="mini" type="primary" @click="checkLogistics(tableData)">查看物流</el-button></el-col>
							<el-col :span="1.5"><el-button
									v-if="[3, 9, 10, 11, 12, 13, 14, 15, 16, 20, 30, 31, 32, 33, 34, 39, 40, 41, 42, 43, 44, 45, 49, 50, 51, 52, 56, 57, 58, 60, 61, 62, 63, 64, 65].indexOf(tableData.status) > -1 && tableData.pact_url != 0 && tableData.sign_status == 2"
									size="mini" type="primary"
									@click="checkPact($globalObj.imgBaseUrl + tableData.pact_url)">查看合同</el-button></el-col>
							<el-col :span="1.5"><el-button v-if="[11, 12, 13, 14].indexOf(tableData.status) > -1" size="mini"
									type="warning" @click="handleRefundOrder(tableData.trade_no)">去处理</el-button></el-col>
							<el-col :span="1.5">
								<el-button
									v-if="[9, 10, 11, 12, 13, 14, 20, 30, 31, 32, 33, 34, 39, 40, 41, 42, 43, 44, 45, 49, 50, 51, 52, 56, 57, 58].indexOf(tableData.status) > -1"
									size="mini" type="success" @click="finishOrder(tableData.id)">交易完成</el-button></el-col>
							<el-col :span="1.5"><el-button v-if="tableData.status == 41" size="mini" type="warning"
									@click="agreeReturn(tableData.id)">同意归还</el-button></el-col>
							<el-col :span="1.5"><el-button v-if="tableData.status == 41" size="mini" type="danger"
									@click="refuseReturn(tableData.id)">拒绝归还</el-button></el-col>
							<el-col :span="1.5"><el-button v-if="tableData.status == 4" size="mini" type="warning"
									@click="handleOrder(tableData.id)">待处理</el-button></el-col>
							<el-col :span="1.5"><el-button size="mini" @click="addRemark(tableData.id)"
									type="primary">添加备注</el-button></el-col>
						</el-row>
					</div>
				</div>
			</div>
			<div class="border_cls">
				<el-row>
					<el-col :span="1">
						<div class="font_cls">用户信息</div>
					</el-col>
				</el-row>
				<el-row :gutter="20">
					<el-col :span="4">
						<div>姓名</div>
					</el-col>
					<el-col :span="4">
						<div>性别</div>
					</el-col>
					<el-col :span="4">
						<div>年龄</div>
					</el-col>
					<el-col :span="4">
						<div>手机</div>
					</el-col>
					<el-col :span="4">
						<div>身份证号码</div>
					</el-col>
					<el-col :span="4">
						<div>地址</div>
					</el-col>
				</el-row>
				<el-row :gutter="20">
					<el-col :span="4">
						<div class="bor_cls">{{ tableData.authentic.cert_name }}</div>
					</el-col>
					<el-col :span="4">
						<div class="bor_cls">{{ tableData.authentic.sex }}</div>
					</el-col>
					<el-col :span="4">
						<div class="bor_cls">{{ tableData.authentic.age }}</div>
					</el-col>
					<el-col :span="4">
						<div class="bor_cls">{{ tableData.mobile }}</div>
					</el-col>
					<el-col :span="4">
						<div class="bor_cls">{{ tableData.cert_no }}</div>
					</el-col>
					<el-col :span="4">
						<div class="bor_cls">{{ tableData.prov + tableData.city + tableData.area + tableData.address }}</div>
						<el-button style="margin-top:10px" size="medium" class="border-btn"
							@click="editAddress(tableData)">修改地址</el-button>
					</el-col>
				</el-row>
				<el-row :gutter="20">
					<el-col :span="4">
						<div>身份证正面</div>
					</el-col>
					<el-col :span="4">
						<div>身份证反面</div>
					</el-col>
				</el-row>
				<el-row :gutter="20">
					<el-col :span="4">

						<div><el-image style="width:200px;height:200px"
								:src="$globalObj.imgBaseUrl + tableData.authentic.idcard_front"
								:preview-src-list="[$globalObj.imgBaseUrl + tableData.authentic.idcard_front]">
							</el-image></div>
					</el-col>
					<el-col :span="4">
						<div><el-image style="width:200px;height:200px"
								:src="$globalObj.imgBaseUrl + tableData.authentic.idcard_back"
								:preview-src-list="[$globalObj.imgBaseUrl + tableData.authentic.idcard_back]">
							</el-image></div>
					</el-col>
				</el-row>
			</div>
			<div class="border_cls">
				<el-row>
					<el-col :span="1">
						<div class="font_cls">租期信息</div>
					</el-col>
				</el-row>
				<el-row :gutter="20">
					<el-col :span="23">
						<div class="flex justify-between" style="gap: 80px;margin-bottom: 10px;">
							<div style="margin-bottom: 20px;">租赁时间: {{ tableData.begin_time }} 至 {{ tableData.end_time }}(共{{
                tableData.month_total }}期)</div>
							<div>总租金：￥{{ tableData.rent_total }}</div>
							<div>买断金：￥{{ tableData.setmeal_price }}</div>
							<div>下期付款金额：￥{{ tableData.lease.next.amount }}</div>
							<div>下期付款时间： {{ tableData.lease.next.date }}</div>
						</div>
						<div>
							<el-table :data="tableData.lease_list" style="width: 100%;text-align: center;border-radius: 8px;" border>
								<el-table-column align="center" label="期数" width="80">
									<template slot-scope="scope">
										<span>{{ scope.row.which_period }}/{{ tableData.month_total }}</span>
									</template>
								</el-table-column>
								<el-table-column align="center" label="租期">
									<template slot-scope="scope">
										<span>{{ scope.row.begin_time }} 至 {{ scope.row.end_time }}</span>
									</template>
								</el-table-column>
								<el-table-column align="center" label="租金">
									<template slot-scope="scope">
										<span>￥{{ scope.row.rent }}</span>
									</template>
								</el-table-column>
								<el-table-column align="center" label="状态" width="100">
									<template slot-scope="scope">
										<el-tag :type="scope.row.status == 0 || scope.row.status == 4 ? '' : 'success'">{{ scope.row.status ==
                      1
                      ? '已支付' : scope.row.status == 2 ? '已退款' : scope.row.status == 4 ? '已买断' : scope.row.status == 4 ?
                        '已逾期' : scope.row.status == 5 ? '线下支付' : '未支付' }}</el-tag>
									</template>
								</el-table-column>
								<el-table-column align="center" label="预计扣款日" prop="begin_time"></el-table-column>
							</el-table>
						</div>
					</el-col>
				</el-row>
			</div>
			<div class="border_cls">
				<el-row>
					<el-col :span="1">
						<div class="font_cls">订单备注</div>
					</el-col>
				</el-row>
				<el-row :gutter="20">
					<el-col :span="23">
						<el-table :data="remarkList" style="width: 100%;text-align: center;border-radius: 8px;" border>
							<el-table-column prop="username" label="操作人员" align="center" />
							<el-table-column prop="remark" label="备注信息" align="center" />
							<el-table-column prop="create_time" label="时间" align="center" />
						</el-table>
					</el-col>
				</el-row>
			</div>
			<check-lease ref="checkLease" :order-id="selectedId"></check-lease>
			<set-address ref="setAddress" :edit-item="editItem" @getList="getList"></set-address>
			<set-device ref="setDevice" :edit-item="editItem" @getList="getList"></set-device>
			<set-remark ref="setRemark" :order-id="selectedId" @getList="getList" :dialog-title="titleDialog">
			</set-remark>
			<check-remark ref="checkRemark" :order-id="selectedId"></check-remark>
			<check-flow ref="checkFlow" :order-no="selectedId"></check-flow>
			<delivery ref="delivery" :order-id="selectedId" @getList="getList"></delivery>
			<receipt ref="receipt" :order-id="selectedId" @getList="getList"></receipt>
			<auth-info ref="authInfo" :edit-item="editItem"></auth-info>
			<check-bill ref="checkBill" :order-id="selectedId"></check-bill>
			<edit-order ref="editOrder" :edit-item="editItem" @getList="getList"></edit-order>
			<select-risk ref="selectRisk" :edit-item="editItem" @getList="getList"></select-risk>
			<select-credit ref="selectCredit" :edit-item="editItem" @getList="getList"></select-credit>
			<check-logistics ref="checkLogistics" :edit-item="editItem"></check-logistics>
			<insurance ref="insurance" :order-id="selectedId" :insurance-list="InsuranceList"></insurance>
			<param-dialog :dialogVisible="dialogVisible" :dialogType="dialogType" :responseInfo="responseInfo"
				:requestInfo="requestInfo" @close="closeDialog"></param-dialog>
			<radar ref="radarDialog" :edit-item="editItem" @getList="getList" @resp-code="respCode"></radar>
			<bill-ab-dialog ref="billAbDialog" :edit-item="editItem" @getList="getList"></bill-ab-dialog>
			<edu-details ref="eduDetails" :edit-item="editItem" />
			<credit-dialog ref="creditDialog" :edit-item="editItem" @getList="getList" />
			<!-- 拒绝归还 -->
			<el-dialog title="拒绝归还" :visible.sync="returnVisible" width="500px">
				<el-form :model="returnForm">
					<el-form-item label="拒绝原因" label-width="120px">
						<el-input v-model="returnForm.checkRefuseReason" autocomplete="off" placeholder="请输入拒绝原因" type="text"
							maxlength="50" show-word-limit></el-input>
					</el-form-item>
				</el-form>
				<div slot="footer" class="dialog-footer">
					<el-button @click="closeReturn">取 消</el-button>
					<el-button type="primary" @click="confirmReturnVisible">确 定</el-button>
				</div>
			</el-dialog>
			<el-dialog width="500px" title="提示" :visible.sync="orderDialogVisible" :close-on-click-modal="false">
				<el-form :model="form" :rules="rules" ref="ruleFormOrder" label-width="100px">
					<el-form-item label="">
						<p>首次查看大数据会使风控余量减1次，后续不扣余量并且可在"营销->布尔数据"内查看，是否确认查看大数据?</p>
					</el-form-item>
					<el-form-item label="请选择分类" prop="goods_type">
						<el-select v-model="form.goodsType" placeholder="全部" @change="handleChange" clearable>
							<el-option v-for="item in goodsType" :key="item.value" :label="item.label"
								:value="item.value"></el-option>
						</el-select>
					</el-form-item>
				</el-form>
				<div slot="footer" class="dialog-footer">
					<el-button size="small" @click="orderDialogVisible = false">取 消</el-button>
					<el-button size="small" type="primary" @click="handleSubmit">确 定</el-button>
				</div>
			</el-dialog>
		</div>

	</div>
</template>

<script>
	import globalData from "../../utils/global"
	import customPage from "@/components/customPage"
	import myDatePicker from "@/components/myDatePicker"
	import {
		orderList,
		getOrderStatus,
		orderListExport,
		orderFinish,
		orderReturnAgree,
		orderReturnRefuse,
		orderComfirmReturn,
		orderReturnFinish,
		orderClose,
		orderRisk,
		getRiskData,
		orderRefuse,
		createCreditCompany,
		orderDetail,
		handleOrder,
		setNextOrder,
		setOrderEdit
	} from "@/api/order"
	import {
		rejectRefund,
		orderCheckPass,
		returnOrder
	} from '../../api/orderRefund'
	import checkLease from './dialogs/checklease';
	import setAddress from '../order/dialogs/setAddress';
	import setDevice from './dialogs/setDevice';
	import setRemark from './dialogs/setRemark';
	import checkRemark from './dialogs/checkRemark';
	import checkFlow from './dialogs/checkFlow';
	import delivery from './dialogs/delivery';
	import receipt from './dialogs/receipt';
	import authInfo from './dialogs/authInfo';
	import checkBill from './dialogs/checkBill';
	import checkLogistics from './dialogs/checkLogistics';
	import editOrder from './dialogs/editOrder';
	import selectRisk from './dialogs/selectRisk';
	import insurance from './dialogs/Insurance';
	import paramDialog from './dialogs/paramDialog';
	import selectCredit from "./dialogs/selectCredit"
	import radar from "./dialogs/radar"
	import eduDetails from './dialogs/eduDetails'
	import billAbDialog from './dialogs/billAbDialog'
	import creditDialog from './dialogs/creditData'
	export default {
		components: {
			creditDialog,
			paramDialog,
			insurance,
			myDatePicker,
			customPage,
			checkLease,
			setAddress,
			setDevice,
			setRemark,
			checkRemark,
			checkFlow,
			delivery,
			receipt,
			authInfo,
			checkBill,
			checkLogistics,
			editOrder,
			selectRisk,
			selectCredit,
			radar,
			eduDetails,
			billAbDialog
		},
		data() {
			return {
				searchForm: {
					orderNo: '',
					goodsName: '',
					receivingName: '',
					receivingMobile: '',
					riskName: '',
					riskMobile: '',
					orderStatus: '',
					orderCreateTime: ''
				},
				searchId: {
					orderId: ''
				},
				form: {
					goodsType: "",
				},
				goodsType: [{
						label: '其他',
						value: 0
					},
					{
						label: '游戏电玩',
						value: 1
					},
					{
						label: '娱乐影音',
						value: 2
					},
					{
						label: '电脑平板',
						value: 3
					},
					{
						label: '手机优选',
						value: 4
					}
				],
				statusList: globalData.orderStatus,
				total: 0,
				tableData: [],
				showFace: false,
				showFront: false,
				showBack: false,
				// activeName: 'all',
				selectedId: '',
				editItem: {},
				selectList: [],
				returnVisible: false,
				refuseId: '',
				returnForm: {
					checkRefuseReason: ''
				},
				InsuranceList: [{
					member_id: 1653450768,
					mechanism: '瑞安市诺明网络科技有限公司'
				}],
				dialogVisible: false,
				orderDialogVisible: false,
				dialogType: 1,
				responseInfo: {},
				requestInfo: {},
				dataItem: {}, // 查看大数据
				eduDialogVisible: false,
				eduForm: {
					order_id: '',
					certificateNo: ''
				},
				eduId: '',
				content: '如果没有输入证书编号，则只能查询简要信息如：(姓名、证件号码、学历层次)',
				newOrderId: '',
				titleDialog: '',
				remarkList: []
			}
		},
		mounted() {
			this.form.goodsType = this.goodsType[4].label
			this.typeId = this.goodsType[4].value
			if (this.$route.params.orderId) {
				this.searchForm.orderNo = this.$route.params.orderId
			}
			this.getSelect()
			this.getList()
		},
		methods: {
			setIsSuccess(setIsSuccess) {
				this.isSuccess = setIsSuccess
			},
			handleRefundOrder(tradeNo) {
				this.$router.push({
					name: 'refundList',
					params: {
						tradeNo
					}
				})
			},
			// 查看合同
			checkPact(url) {
				window.open(url)
			},

			// 征信数据
			creditDialog(item) {
				getCreditData(item.id).then(res => {})
				setTimeout(() => {
					getCreditData(item.id).then(res => {})
				}, 1000)
				setTimeout(() => {
					this.getList()
				}, 4000)

			},
			// 征信数据
			creditDialog2(item) {
				this.$confirm('是否确认查看征信风控数据?', '提示', {
						confirmButtonText: '确定',
						cancelButtonText: '取消'
					})
					.then(() => {
						this.editItem = {
							orderId: item.id,
							trade_no: item.trade_no,
							cert_name: item.cert_name,
							cert_no: item.cert_no,
							mobile: item.mobile
						}
						this.$refs.creditDialog.dialogVisible = true

					})
					.catch(() => {})
			},
			// 订单完结
			finishOrder(id) {
				this.$confirm('交易完成后进行解约现有款项不退款，并解约代扣无法发起未代扣的期数！', '请确认是否交易完成？', {
					confirmButtonText: '确定',
					cancelButtonText: '取消'
				}).then(() => {
					orderFinish(id).then(res => {
						this.getList()
					});
				}).catch(() => {})
			},
			// 同意归还
			agreeReturn(id) {
				this.$confirm('确定要同意归还吗？', '同意归还', {
					confirmButtonText: '确定',
					cancelButtonText: '取消'
				}).then(() => {
					orderReturnAgree(id).then(res => {
						this.getList()
					});
				}).catch(() => {})
			},
			// 拒绝归还
			refuseReturn(id) {
				this.refuseId = id
				this.returnVisible = true
			},
			// 订单关闭
			closeOrder(id) {
				this.$confirm('确定要关闭订单吗？', '关闭', {
					confirmButtonText: '确定',
					cancelButtonText: '取消'
				}).then(() => {
					orderClose(id).then(res => {
						this.getList()
					});
				}).catch(() => {})
			},
			// 审核拒绝
			refuseOrder2(id) {
				this.$confirm('确定要拒绝订单吗？', '拒绝', {
						confirmButtonText: '确定',
						cancelButtonText: '取消'
					})
					.then(() => {
						orderRefuse(id).then((res) => {
							this.getList()
						})
					})
					.catch(() => {})
			},
			closeReturnEdu() {
				this.eduDialogVisible = false
				this.eduForm.certificateNo = ''
			},
			closeReturn() {
				this.returnVisible = false
				this.returnForm.checkRefuseReason = ''
			},
			confirmReturnVisible() {
				if (!this.returnForm.checkRefuseReason) {
					this.$message.warning('拒绝原因不能为空')
					return false
				}
				orderReturnRefuse({
					orderId: this.refuseId,
					checkRefuseReason: this.returnForm.checkRefuseReason
				}).then((res) => {
					this.getList()
					this.closeReturn()
				}).catch(() => {})
			},
			// 确认归还
			confirmReturn(id) {
				this.$confirm('确定要归还吗？', '确认归还', {
					confirmButtonText: '确定',
					cancelButtonText: '取消'
				}).then(() => {
					orderComfirmReturn(id).then(res => {
						this.getList()
					})
				}).catch(() => {})
			},
			// 查看物流
			checkLogistics(item) {
				this.editItem = item
				this.$refs.checkLogistics.dialogVisible = true
			},
			// 查看已付账单详情
			checkPaidBill(id, paid_rent) {
				if (this.$hasMethod('#checkBill') && paid_rent > 0) {
					this.selectedId = id
					this.$refs.checkBill.dialogVisible = true
				}
			},
			// 确认收货
			confirmReceipt(id) {
				this.selectedId = id
				this.$refs.receipt.dialogVisible = true
			},
			// 订单发货
			openDelivery(id) {
				this.selectedId = id
				this.$refs.delivery.dialogVisible = true
			},
			// 拒绝订单
			refuseorder(id) {
				this.$confirm('请确认是否拒绝该订单?', {
						confirmButtonText: '确定',
						cancelButtonText: '取消'
					})
					.then(() => {
						rejectRefund({
								order_id: id
							})
							.then((res) => {
								// console.log(res);
								this.getList()
							})
							.catch(() => {})
					})
					.catch(() => {})
			},
			// 审核通过
			checkPass(id) {
				this.$confirm('需要上征信的订单必须要在审核通过前执行上征信操作完成，请确认是否审核通过该订单?', {
						confirmButtonText: '确定',
						cancelButtonText: '取消'
					})
					.then(() => {
						orderCheckPass({
								orderId: id
							})
							.then((res) => {
								// console.log(res);
								this.getList()
							})
							.catch(() => {})
					})
					.catch(() => {})
			},
			// 转回平台
			returnOrder(id) {
				this.$confirm('是否拒绝该订单并转回平台?', {
						confirmButtonText: '确定',
						cancelButtonText: '取消'
					})
					.then(() => {
						returnOrder({
								orderId: id
							})
							.then((res) => {
								// console.log(res);
								this.getList()
							})
							.catch(() => {})
					})
					.catch(() => {})
			},
			// 查看流水记录
			viewFlow(trade_no) {
				this.selectedId = trade_no
				this.$refs.checkFlow.dialogVisible = true
			},
			// 查看客服备注
			viewRemark(id) {
				this.selectedId = id
				this.$refs.checkRemark.dialogVisible = true
			},
			// 添加客服备注
			addRemark(id) {
				this.titleDialog = "客服备注"
				this.selectedId = id
				this.$refs.setRemark.dialogVisible = true
			},
			// 更改设备编号
			editDevice(item) {
				this.editItem = {
					orderId: item.id,
					deviceNumber: item.device_number ? item.device_number.split(',') : [],
					amount: item.amount
				}
				this.$refs.setDevice.dialogVisible = true
			},
			// 修改地址
			editAddress(item) {
				this.editItem = {
					orderId: item.id,
					realname: item.realname,
					mobile: item.address_mobile,
					address: item.address,
					prov: item.prov,
					city: item.city,
					area: item.area,
					province: [item.prov, item.city, item.area]
				}
				console.log(this.editItem);
				this.$refs.setAddress.dialogVisible = true
			},
			// 查看租期
			viewLease(id) {
				this.selectedId = id
				this.$refs.checkLease.dialogVisible = true
			},
			// 编辑订单
			editorder(item, num) {
				// 1 租赁方式  2 每期租金 3 买断金 4 更改押金
				this.editItem = {
					orderId: item.id,
					pact_type: item.pact_type_number,
					month_total: item.month_total,
					setmeal_price: item.setmeal_price,
					rent: '',
					activity_id: item.activity_id > 0 ? 1 : 2,
					setmeal_foregift_apply: item.setmeal_foregift_apply ? item.setmeal_foregift_apply : 0,
					setmeal_foregift: item.setmeal_foregift,
					num: num
				}
				this.$refs.editOrder.dialogVisible = true
			},
			// 布尔数据
			handleOrderData(item) {
				this.dataItem = item
				this.orderDialogVisible = true
			},
			handleOrder(id) {
				this.$confirm('确定稍后处理?', '提示', {
						confirmButtonText: '确定',
						cancelButtonText: '取消'
					})
					.then(() => {
						handleOrder({
							orderId: id
						}).then(res => {
							this.$message({
								message: "操作成功！",
								type: "success"
							})
							this.getList()
						})
					})
					.catch(() => {})
			},
			// 查看雷达风控数据
			radarDialog(item) {
				this.$confirm('首次查看雷达大数据会使风控余量减1次，后续不扣余量并且可在"营销->布尔数据"内查看，是否确认查看大数据?', '提示', {
						confirmButtonText: '确定',
						cancelButtonText: '取消'
					})
					.then(() => {
						this.editItem = {
							orderId: item.id,
							cert_name: item.authentic.cert_name,
							cert_no: item.authentic.cert_no,
							mobile: item.mobile
						}
						console.log(this.editItem);
						this.$refs.radarDialog.dialogVisible = true
						this.respCode()
					})
					.catch(() => {})
			},
			respCode(data) {
				console.log(data);
				if (data.length == 0) {
					this.$message({
						message: "该用户没有雷达风控数据风险",
						type: "error"
					})
				}
			},
			handleSubmit() {
				this.$refs['ruleFormOrder'].validate((valid) => {
				if (valid) {
					  this.editItem = {
						orderId: this.dataItem.id,
						cert_name: this.dataItem.cert_name,
						cert_no: this.dataItem.cert_no,
						mobile: this.dataItem.mobile,
						rent_total: this.dataItem.rent_total,
						month_total: this.dataItem.month_total,
						website_price: this.dataItem.website_price,
						new_grade: this.dataItem.new_grade,
						goods_type: this.typeId
					  }
					  this.orderDialogVisible = false
					  this.$refs.selectRisk.dialogVisible = true
				} else {
				  this.$message({
					message: "请选择类型",
					type: "error"
				  })
				  return false
				}
				})
			},
			getOrderStatusType(status) {
				const obj = this.statusList.find(item => item.id === status)
				return obj ? obj.type : 'warning'
			},
			getOrderStatusName(status) {
				const obj = this.statusList.find(item => item.id === status)
				return obj ? obj.name : ''
			},
			// 获取数据
			getList(flag) {
				// flag为true, 则不刷新表格
				// const { page, pageSize } = this.$refs.customPage
				this.remarkList = []
				if (!flag) {
					console.log(1);
					this.tableData = []
				}
				orderDetail({

				}).then(res => {
					this.tableData = res
					this.tableData.orderRemark.find(item => {
						if (item.type == 9) {
							this.remarkList.push(item)
						}
					})
				})
			},
			// 查询
			search() {
				const pickerVal = this.$refs.myDatePicker.getVal()
				if (pickerVal !== 'error') {
					this.searchForm.orderCreateTime = pickerVal
					this.$refs.customPage.page = 1
					this.getList()
				}
			},
			// 重置
			reset() {
				if (this.$refs.myDatePicker) {
					this.$refs.myDatePicker.reset()
				}
				this.searchForm = {
					orderNo: '',
					goodsName: '',
					receivingName: '',
					receivingMobile: '',
					riskName: '',
					riskMobile: '',
					orderStatus: '',
					orderCreateTime: ''
				}
				this.getList()
			},
			// 导出
			exportFile() {
				const pickerVal = this.$refs.myDatePicker.getVal()
				if (pickerVal !== 'error') {
					this.searchForm.orderCreateTime = pickerVal
					orderListExport({
						...this.searchForm,
						orderStatusGroup: this.activeName
					})
				}
			},
			handleClick(tab) {
				this.activeName = tab.name
				this.$refs.customPage.page = 1
				this.getList()
			},
			handleSet() {
				setNextOrder(this.searchId.orderId).then(res => {
					console.log(res);
					// this.tableData = res
					this.$message({
						message: "设置成功",
						type: "success"
					})
				})
			},
			getSelect() {
				getOrderStatus().then(res => {
					const list = []
					for (const key in res) {
						list.push({
							id: key,
							name: res[key]
						})
					}
					this.selectList = list || []
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.el-row {
		margin-bottom: 10px;
	}

	.bor_cls {
		border: 1px solid #DCDCDC;
		padding: 5px;
		border-radius: 3px 3px 3px 3px;
		font-size: 14px;
	}

	.container {
		background-color: #EEEEEE;
	}

	.goods_cls div {
		margin-bottom: 20px;
	}

	.item {
		margin-left: 10px;
	}

	.border_cls {
		padding: 20px;
		margin-bottom: 20px;
		background: #FFFFFF;
		box-shadow: 0px 0px 4px 0px rgba(0, 0, 0, 0.06);
		border-radius: 4px 4px 4px 4px;
	}

	.font_cls {
		font-size: 16px;
		font-family: Microsoft YaHei-Bold, Microsoft YaHei;
		font-weight: bold;
		color: #2993ff;
	}

	.btn_cls {
		position: relative;
		bottom: -200px;

		.el-button {
			margin-bottom: 20px;
		}
	}

	.common_form_search {
		padding: 15px 30px 0;
	}

	.child_page {
		padding-bottom: 15px;
		padding-left: 30px;
		padding-right: 30px;

		p,
		div {
			box-sizing: border-box;
		}
	}

	.list_wrap {
		position: relative;
	}

	.list_header {
		position: sticky;
		top: 0;
		left: 0;
		right: 0;
		min-height: 50px;
		z-index: 2;
		background: #f5f5f5;
		border: 1px solid #e6e6e6;

		p {
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 16px;
		}

		p:not(:first-child) {
			border-left: 1px solid #e6e6e6;
		}
	}

	.list_item {
		display: block;
		border: 1px solid #e6e6e6;
		margin-top: 10px;
	}

	.item_row {
		border-top: 1px solid #e6e6e6;

		&>div {
			padding: 10px;
			color: #666666;

			&:not(:first-child) {
				border-left: 1px solid #e6e6e6;
			}
		}
	}

	.detail,
	.btns {
		padding: 10px;
	}

	.every {
		border-bottom: 1px solid #f5f5f5;
		margin-top: -60px;
		padding-bottom: 0;
	}

	.every .el-tag {
		width: 74px;
		text-align: center;
		font-size: 14px;
	}

	.btns {

		// border-left: 1px solid #e6e6e6;
		.el-button+.el-button {
			margin-left: 10px;
		}
	}

	.border-btn {
		width: 150px;
		height: 30px;
		margin-bottom: 10px;
		padding-top: 0;
		padding-bottom: 0;
		background: #ffffff;
		border: 1px solid $mainBlue;
		border-radius: 3px;
		color: $mainBlue;
		font-size: 12px;
	}

	.sign_icons img {
		// width: 21px;
		height: 23px;
		margin-right: 2px;
	}

	.item_header {
		padding: 5px 10px;
		background-color: #f5f5f5;

		&>div p {
			color: #666666;
			font-size: 12px;
			padding-left: 20px;
		}
	}

	.title {
		font-size: 16px;
		line-height: 23px;
		padding-bottom: 15px;
	}

	.meal,
	.device {
		font-size: 12px;
		color: #999999;
		line-height: 23px;
	}

	.item_row p {
		line-height: 23px;
	}

	.item_row div {
		line-height: 20px;
	}

	.btns {
		padding-left: 0;
	}

	.btns .el-button {
		margin-left: 10px;
		margin-bottom: 10px;
	}

	.text-ellipsis span {
		color: purple;
	}

	.el-image-viewer__wrapper {
		z-index: 2090 !important;
	}
</style>